package com.corpdata.app.customer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RequestParam;
import com.corpdata.app.customer.entity.CustomerStaff;
import com.corpdata.app.customer.service.CustomerStaffService;
import com.corpdata.common.domain.DataGridRequestDTO;
import com.corpdata.common.result.Result;
import com.corpdata.system.log.OptLog;
import com.corpdata.system.log.WebLog;
import com.corpdata.core.base.BaseController;

/**
 * 团队员工
 * 
 * @author wu
 * @email 64088839@qq.com
 * @date 2018-06-13 16:46:46
 */
 
@Controller
@RequestMapping("app/customerStaff")
public class CustomerStaffController extends BaseController{

	@Autowired
	private CustomerStaffService customerStaffService;
	
	//新增页面
	@GetMapping("/add/{id}")
	public String add(@PathVariable("id") String id,ModelMap map){
		map.put("id", id);
		return "app/customer/staff/staff_add";
	}
	
	//保存数据
	@WebLog()
	@ResponseBody
	@RequestMapping("/save")
	@OptLog(info="创建员工",module="团队员工")
	public Result save(CustomerStaff record){
		return customerStaffService.save(record);
	}
	
	//编辑页面
	@RequestMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id,ModelMap map){
		map.put("record", customerStaffService.findById(id));
		return "app/customer/staff/staff_edit";
	}
	
	//更新数据
	@WebLog()
	@ResponseBody
	@RequestMapping("/update")
	@OptLog(info="修改员工",module="团队员工")
	public Result update(CustomerStaff record){
		return customerStaffService.update(record);
	}
	
	//删除
	@WebLog()
	@ResponseBody
	@PostMapping("/delete")
	@OptLog(info="删除员工",module="团队员工")
	public Result delete(String id){
		return customerStaffService.deleteById(id);
	}
	
	//批量删除
	@WebLog()
	@ResponseBody
	@PostMapping("/deletes")
	public Result deletes(@RequestParam("ids[]") String[] ids){
		return customerStaffService.deleteByIds(ids);
	}
	
	//详情页面
	@GetMapping("/details/{id}")
	public String details(ModelMap map,@PathVariable("id") String id){
		map.put("record", customerStaffService.findById(id));
	    return "app/customer/staff/staff_details";
	}
	//详情页面-基本信息
	@GetMapping("/detailsBasic/{id}")
	public String detailsBasic(ModelMap map,@PathVariable("id") String id){
		map.put("record", customerStaffService.findById(id));
	    return "app/customer/staff/staff_details_basic";
	}
	//列表页面
	@GetMapping("/list/{id}")
	public String list(ModelMap map,@PathVariable("id") String id){
		map.put("id",id);
	    return "app/customer/staff/staff_list";
	}
	
	//列表数据
	@ResponseBody
	@RequestMapping("/listdata")
	public String findByPage(DataGridRequestDTO dgRequest){
		return customerStaffService.findByPage(dgRequest);
	}
	
	//下拉数据
	@ResponseBody
	@RequestMapping("/selectjson/{id}")
	public String getSelectJsonData(@PathVariable("id") String id){
		return customerStaffService.selectAllByCombox(id);
	}
	
	//员工详情信息
	@ResponseBody
	@RequestMapping("/selStaff/{id}")
	public String selStaff(@PathVariable("id") String id){
		return customerStaffService.selStaff(id);
	}
}
